<template>
	<view>
		<custom title="购买记录" fixed="fixed"></custom>



		<view style="padding: 0 20rpx;">
			<view style="padding: 30rpx;border-radius: 20rpx;" class="mt-20 flex flex-y-center bg-FFFFFF"
				v-for="(item,index) in list" :key="index">
				<view class="flex-1 over-line1">
					<view class="fs-22 color-999999">{{item.time}}</view>
					<view class="fs-30 color-333333 mt-10">发个信{{item.level == 2?'svip':'vip'}}会员</view>
					<view class="fs-22 color-999999 mt-10">订单号: {{item.orderId}}</view>
				</view>
				<view class="color-all">
					¥{{item.amt}}
				</view>
			</view>
		</view>



		<qq-footer :show="is_null" :list="list"></qq-footer>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				statusbar: getApp().globalData.statusBar + 'px',
				tabs_list: [
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// },
					// {
					// 	name: '全部'
					// }
				],
				tab_index: 0,
				list: [],
				page: 1,
				is_null: false,
			};
		},
		mounted() {


		},
		created() {


		},
		onShow() {


		},
		computed: {
			get_left() {
				if (this.tab_index > 3) {
					return 35 * this.tab_index;
				}
				return 0;
			},
		},
		onLoad() {


			this.init();


		},
		onReachBottom() {
			this.get_list(this.page);
		},
		onPullDownRefresh() {


			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 200);
			this.init();

		},
		methods: {
			tab_change(index) {
				this.tab_index = index;
				this.init();
			},


			init() {
				this.setData({
					page: 1,
					list: [],
					is_null: false,
				})

				this.get_list();
			},
			get_list(page = 1) {
				let data = {
					page: page,
					size: 20,
				};
				if (this.tab_index > -1 && this.tabs_list.length > 0) {
					data.goodsType = this.tabs_list[this.tab_index].id || ''
				}
				this.request({
					url: '/vip/orderVipList',
					data,
					loading: page == 1,
				}).then(res => {
					if (!this.rsuccess(res)) return;
					let list = res.data?.records || [];
					
					list.forEach(val => {
						val.time = this.dateFormat('YYYY-mm-dd HH:MM:SS', new Date(val.createTime));
					});

					this.list = this.list.concat(list || []);
					

					

					if (res.data?.records?.length < 20) {
						this.is_null = true;
					} else {
						this.page++;
					}

				});
			}
		},
	}
</script>
